﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AcadPosApp
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                base.OnLoad(e);
                Page.Header.DataBind();
            }
            catch (System.Exception)
            {
                Response.Redirect("~/login.aspx");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string strPaginaAtual = Request.CurrentExecutionFilePath;
            strPaginaAtual = strPaginaAtual.Remove(0, strPaginaAtual.LastIndexOf("/") + 1);
            //if (strPaginaAtual.Equals("MatriculaAluno.aspx"))
            //{
            //    Session.Remove("saidaPagina");
            //    Session.Remove("idMatriculaSituacao");
            //    Session.Remove("matriculaSessao");
            //}

            if (Session["msg"] != null)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Alert", string.Format("alert('{0}');", Session["msg"].ToString()), true);
                Session["msg"] = null;
            }
        }

        protected void btnAlterarSenha_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Seguranca/AlterarSenha.aspx");
        }

        protected void btnSair_Click(object sender, EventArgs e)
        {
            TrustX.Security.Usuario.LogoutSistema();
            Response.Redirect("~/login.aspx");
        }

        protected void ImgLogo_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("~/Default.aspx");
        }
    }
}
